package com.jiangjiang.eshop.wms.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiangjiang.eshop.wms.convert.PurchaseInputOrderPutOnItemConvert;
import com.jiangjiang.eshop.wms.dao.PurchaseInputOrderPutOnItemMapper;
import com.jiangjiang.eshop.wms.domain.PurchaseInputOrderPutOnItem;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderDTO;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderPutOnItemDTO;
import com.jiangjiang.eshop.wms.dto.PurchaseInputOrderQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

/**
 * @ClassName PurchaseInputOrderPutOnItemService
 * @Description TODO
 * @Author jhw
 * @Date 2021/9/13 21:58
 * @Version 1.0
 **/
@Service
public class PurchaseInputOrderPutOnItemService extends ServiceImpl<PurchaseInputOrderPutOnItemMapper, PurchaseInputOrderPutOnItem> {

    @Autowired
    private PurchaseInputOrderPutOnItemConvert purchaseInputOrderPutOnItemConvert;

    /**
     * 根据采购入库单明细id集合查询上架明细记录
     * @param itemIds 采购入库单明细id集合
     * @return 查询结果
     */
    public List<PurchaseInputOrderPutOnItemDTO> queryByItemIds(List<Long> itemIds) {
        LambdaQueryWrapper<PurchaseInputOrderPutOnItem> wrapper = Wrappers.lambdaQuery();
        wrapper.in(PurchaseInputOrderPutOnItem::getPurchaseInputOrderItemId, itemIds);
        return purchaseInputOrderPutOnItemConvert.convertEntities2DTOList(this.list(wrapper));

    }

    /**
     * 批量保存上架明细数据
     * @param dtoList 上架明细DTO 集合
     * @return 处理结果
     */
    public Boolean batchSavePutOnItems(List<PurchaseInputOrderPutOnItemDTO> dtoList) {
        return this.saveBatch(purchaseInputOrderPutOnItemConvert.convertDTOList2Entities(dtoList));
    }
    
}
